<template>
  <div class="commentItem">
    <div class="top">
      <div class="left">
        <span>{{ obj.user.nickname }}</span> &nbsp;&nbsp;&nbsp;
        <span>2分钟前</span>
      </div>
      <span @click="replyFn(obj.id)">回复</span>
    </div>
    <!-- 嵌套的第二层，在外面也就是第三层star -->
    <commentItem
      @sendData="replyFn"
      v-if="obj.parent"
      :obj="obj.parent"
    ></commentItem>
    <!-- 嵌套的第二层，在外面也就是第三层end -->
    <div class="bottom">{{ obj.content }}</div>
  </div>
</template>

<script>
export default {
  name: "commentItem",
  props: {
    obj: {
      type: Object,
      required: true,
    },
  },
  components: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {
     console.log(38,this.obj);
  },
  mounted() {
   
  },
  methods: {
    replyFn(id) {
      // 子传父
      this.$emit("sendData", id);
    },
  },
};
</script>

<style scoped lang="less">
.commentItem {
  border: 1px solid #ccc;
  padding: 5px;
  margin-top: 10px;
  .top {
    font-size: 12px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
  }
  .bottom {
    font-size: 13px;
    line-height: 40px;
  }
}
</style>
